/**
 * @(#) NXTLightSensor.java
 */

package pcsr.drivers.nxtDriver;

import pcsr.drivers.nxtDriver.command.INXTCommand;

class NXTLightSensor extends NXTSensor
{
	NXTLightSensor( NXTPort sensor, INXTCommand command ) {
		super(sensor, command);		
		setTypeAndMode(NXTSensorType.LIGHTACTIVE, NXTSensorMode.PCTFULLSCALE);
	}

	@Override
	public double GetSensorValue( ) {
		return readNormalizedValue();
	}
	
	/**
	 * Returns light reading as a percentage.
	 * @return 0 to 100 (0 = dark, 100 = bright)
	 */
	public int getLightPercent( ) {
		return readScaledValue();
	}
	
	/**
	 * Turns off the LED light so it can passively read light values.
	 * 
	 */
	public void passivate( ) {
		setTypeAndMode(NXTSensorType.LIGHTINACTIVE, NXTSensorMode.PCTFULLSCALE);
	}
	
	/**
	 * Turns on the LED light.
	 * 
	 */
	public void activate( ) {
		setTypeAndMode(NXTSensorType.LIGHTACTIVE, NXTSensorMode.PCTFULLSCALE);
	}

	@Override
	public NXTSensorMode[] GetAvailableModes( ) {
		// TODO Auto-generated method stub
		return new NXTSensorMode[]{NXTSensorMode.PCTFULLSCALE};
	}

	@Override
	int UpdateActuatorState( ) {
		SetSensorValue(readNormalizedValue());
		return 0;
	}
}
